package me.lcc.demo.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import me.lcc.demo.model.Account;
import me.lcc.demo.repository.AccountRepository;
import me.lcc.demo.utils.AccountUtils;

/**
 * 演示
 */
@Controller
public class HelloController {
	@Autowired
	AccountRepository accountRepository;
	
	@ResponseBody
	@GetMapping("/admin")
	public String admin() {
		return "["+AccountUtils.currentLoginAccount().getUsername()+"] Hello admin";
	}
	@ResponseBody
	@GetMapping("/hello/fruit/apple")
	public String apple() {
		return "["+AccountUtils.currentLoginAccount().getUsername()+"] Hello apple";
	}
	@ResponseBody
	@GetMapping("/hello/baby")
	public String baby() {
		return "["+AccountUtils.currentLoginAccount().getUsername()+"] Hello baby";
	}

	@ResponseBody
	@GetMapping("/hello/account")
	public List<Account> account() {
		return accountRepository.findAll();
	}
}
